<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">		
<title><?php echo $title ?></title>
<?php require("lib.php"); ?>
</head>
<body>
<div class="content-box"><!-- Start Content Box -->
    <div class="content-box-header">
        <h3><?php echo $title ?></h3>
        <div class="clear"></div>
    </div> <!-- End .content-box-header -->
    <div class="content-box-content">
<?php
  switch ($do) {
    case "add":
    	add();
    	break;
	case "update":
		update($info);
		break;
	case "delete":
		delete($id);
		break;
    default:	
		show_info($info);
  }
 ?>
<?php function show_box($row, $iseditmode){
	global $id, $title, $url;
?>
	<table width="99%" cellspacing="0" cellpadding="3" class="mbox">
      <tr class="th"><td class="thtitle" width="120" align="right"><?php echo $title ?></td><td><input value="<?php echo decode($row["id"]) ?>" name="id" type="hidden"></td></tr>
      <tr><td class="l"><?=ROOT_FULLNAME?></td><td><? echo decode($row["name"]) ?></td></tr>
      <tr><td class="l"><?=ROOT_PHONE?></td><td><? echo decode($row["phone"]) ?></td></tr>
      <tr><td class="l"><?=ROOT_EMAIL?></td><td><? echo decode($row["email"]) ?></td></tr>
      <tr><td class="l"><?=ROOT_FEEDBACK?></td><td><? echo decode($row["content"]) ?></td></tr>
      <tr><td class="l"><?=ROOT_FEEDBACK_TIME?></td><td><? echo decode($row["created_time"]) ?></td></tr>
      <tr><td class="l">&nbsp;</td><td><br><input <?php if(!$iseditmode)echo "class='hide'";?> name="save" type="submit" value="&nbsp; <?=ROOT_SAVE?> &nbsp;">&nbsp;&nbsp;<a onClick="history.go(-1)">[ <?=ROOT_BACK?> ]</a><br><br></td></tr>
    </table>
    <?php } ?>
	<?php function show_boxes($result){
		global $page, $pages, $cateid, $h, $url;
		echo $h->form($url.'.php', 0, ''); // 构建删除多项表单 form for deleting muti rows
		echo $h->hidden('action', 'deletes'); // 
		echo $h->hidden('page', $page); // 当前页面 current page
		echo $h->hidden('cateid', $cateid); // 当前分类 current category
		$str= '<table width="99%" cellspacing="0" cellpadding="3" class="mlist"><tr class="th"><td width="48"><input type="checkbox" name="aller" class="check-all" /> '.ROOT_SELECT_ALL.'</td><td><strong>#</strong></td><td><strong>'.ROOT_FULLNAME.'</strong></td><td><strong>'.ROOT_PHONE.'</strong></td><td><strong>'.ROOT_EMAIL.'</strong></td><td><strong>'.ROOT_FEEDBACK_TIME.'</strong></td><td><a class="nada" href="message.php?a=add">[ '.ROOT_ADD.' ]</a></td></tr>';
		$count=1;
    	foreach( $result as $row)
		{
			$id=decode($row['id']);
      		$str.="<tr><td><input type='checkbox' name='all[]' value='$id' /></td><td>".$id.".</td><td><a href=\"$url.php?id=".$id."\">".decode($row['name'])."</a></td><td>".decode($row['phone'])."</td><td>".decode($row['email'])."</td><td>".decode($row['created_time'])."</td><td>";
			$str.="<a href=\"$url.php?id=".$id."\">".ROOT_DETAIL."</a> | <a href=\"$url.php?do=delete&id=".$id."\" onClick=\"javascript: return delc();\">".ROOT_DELETE."</a></td></tr>";
			$str.="<tr><td colspan='7' class='gray'>".ROOT_FEEDBACK.": ".d($row['content'])."</td></tr>";
			$count++;
		}
		$str.="<tr><td colspan='7'><input type='checkbox' name='aller' class='check-all' /> ".ROOT_SELECT_ALL." <input class='button' type='submit' value='".ROOT_DELETE_SELECTED."' onClick=\"javascript: return delc();\" /></td></tr></table>";
		if($count==1) $str.= "<br>".ROOT_NO_DATA."!";
		echo $str;
		echo $h->former();
		echo echo_page($page, $pages, $url.'-'.$cateid.'-p');
     } ?>
	<br class="clear" />
	</div> <!-- End .content-box-content -->
    <br class="clear" />
	</div><!-- End .content-box -->
</body>
</html>